<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use think\Db;

class Activity extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 活动主页
     */
    public function active()
    {
        return $this->view->fetch();
    }

    /**
     * 活动结束页
     */
    public function ending()
    {
        $params = $this->request->param();
        $activityId = $params['activityId'];
        $userId  = $params['userId'];
        $where = array(
            'activity_id'=>$activityId,
            'user_id' => $userId
        );
        $myInfo = Db::name('receive')->where($where)->field('recommend_num,invite_quantity')->find();
        $recommendList = Db::name('receive')->where('activity_id',$activityId)->where('recommended_id',$userId)->field('mobile,email,recommended_amount')->select();
        $list = json_encode($recommendList);
        $this->assign('myInfo',$myInfo);
        $this->assign('list',$list);

        return $this->view->fetch();
    }

    /**
     * 下载页
     */
    public function download()
    {
        return $this->view->fetch();
    }
}
